import 'package:flutter/material.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';

class MGSwitchMonry extends StatefulWidget {
  final String title;
  final String? showIcon;
  final String? hiddleIcon;
  final double? monry;
  final Color color;
  final bool showExchange;
  final CrossAxisAlignment crossAxisAlignment;
  MGSwitchMonry({
    super.key,
    this.title = "账户余额(元)",
    this.showIcon,
    this.hiddleIcon,
    this.monry,
    this.color = Colors.white,
    this.showExchange = true,
    this.crossAxisAlignment = CrossAxisAlignment.start,
  });

  @override
  State<MGSwitchMonry> createState() => _MGSwitchMonryState();
}

class _MGSwitchMonryState extends State<MGSwitchMonry> {
  String _showIconsImage = "";
  String _hiddleIconsImage = "";
  bool _hiddleExchange = true;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _showIconsImage = (widget.showIcon != null) ? widget.showIcon! : MGImage.image("public_show", type: ImagePathType.public);
    _hiddleIconsImage = (widget.hiddleIcon != null) ? widget.hiddleIcon! : MGImage.image("public_hiddle", type: ImagePathType.public);
    _hiddleExchange = widget.showExchange;
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Text(widget.title,
                style: TextStyle(
                  color: widget.color,
                  fontSize: MGFont.textFont1,
                  fontWeight: FontWeight.bold,
                )),
            widget.showExchange
                ? InkWell(
                    child: Container(
                      padding: EdgeInsets.only(left: 12),
                      child: ImageIcon(
                        AssetImage(_hiddleExchange ? _hiddleIconsImage : _showIconsImage),
                        color: widget.color,
                      ),
                    ),
                    onTap: () {
                      setState(() {
                        _hiddleExchange = !_hiddleExchange;
                      });
                    },
                  )
                : Container()
          ],
          mainAxisAlignment: MainAxisAlignment.center,
        ),
        SizedBox(height: 5),
        Text(_hiddleExchange ? "******" : (widget.monry ?? 0.00).toStringAsFixed(2),
            style: TextStyle(
              color: widget.color,
              fontSize: MGFont.titleFont2,
              fontWeight: FontWeight.bold,
            ))
      ],
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: widget.crossAxisAlignment,
    );
  }
}
